<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>
<%@ taglib uri="http://liferay.com/tld/security" prefix="liferay-security"%>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ page import="javax.portlet.PortletPreferences"%>
<%@ page import="java.util.List"%>
<%@ page import="com.juani.test.model.Client"%>
<%@ page import="com.juani.test.service.ClientLocalServiceUtil"%>


<portlet:defineObjects />
<liferay-theme:defineObjects/>

<% 
	List<Client> clients = ClientLocalServiceUtil.getClients(0, Integer.MAX_VALUE);
	int clientsCount = clients.size();
%>

<liferay-ui:header title="Client List"/>

<liferay-ui:error key="unknow-error" message="unknow-error" />
<liferay-ui:error key="no-such-client" message="no-such-client" />
<liferay-ui:success key="deleted-client" message="deleted-client"></liferay-ui:success>

<table id="client-list">
	<thead>
		<tr>
			<th>First Name</th>
			<th>Last Name</th>
			<th>E-mail</th>
			<th>Address</th>
			<th>Phone</th>
			<th>Movil</th>
			<th>Actions</th>
		</tr>
	</thead>
	<tbody>
		<c:forEach items="<%= clients %>" var="client">
			<tr>
				<td>${client.firstName}</td>
				<td>${client.lastName}</td>
				<td>${client.email}</td>
				<td>${client.address}</td>
				<td>${client.phone}</td>
				<td>${client.movil}</td>
				
				<portlet:actionURL name="edit" var="editURL">
					<portlet:param name="clientId" value="${client.clientId}"/>
				</portlet:actionURL>
				
				<portlet:actionURL name="delete" var="deleteURL">
					<portlet:param name="clientId" value="${client.clientId}"/>
				</portlet:actionURL>
				<td>
					<a href="${editURL}">Edit</a>&nbsp;
					<a href="${deleteURL}">Delete</a>
				</td>
			</tr>
		</c:forEach>
	</tbody>
</table>
<p>
	Total Clients: <%= clientsCount %> &nbsp;&#124;&nbsp;<a href="<portlet:actionURL name="edit" />">Add New Client</a>
</p>
